import instance from '../util/api'
//上传准备
export const beforeUpload = async (
  userId,
  filePid,
  fileMd5,
  fileSize,
  fileName
) => {
  const res = await instance.post('/file/judgeFile', {
    userId,
    filePid,
    fileMd5,
    fileSize,
    fileName
  })
  return res.data
}
// 上传分片ing（开始请求上传文件）
export const uploading = () => {
  return instance.getUri
}
// export const Uploading = async (
//   userId,
//   filePid,
//   fileMd5,
//   fileSize,
//   chunkNumber
// ) => {
//   const res = await instance.post('/file/uploadFileChunk', {
//     userId,
//     filePid,
//     fileMd5,
//     fileSize,
//     chunkNumber
//   })
//   return res.data
// }
// 合并分片上传完成后发请求
export const afterUpload = async (
  userId,
  filePid,
  fileMd5,
  fileName,
  totalChunks
) => {
  const res = await instance.post('/file/mergeFile', {
    userId,
    filePid,
    fileMd5,
    fileName,
    totalChunks
  })
  return res
}
//取消上传
export const cancelUpload = async (userId, filePid, fileMd5) => {
  const res = await instance.post('/file/cancelUpload', {
    userId,
    filePid,
    fileMd5
  })
  return res.data
}
